test(components): add tests for Switch, Radio, Checkbox - #223
Conversation
Batch 3 of issue #214's component test rollout — 20 tests across 3 suites. Duplicates the shared test infra from batch-1/2 (test-utils render helper, @expo/vector-icons mock, @types/react-test-renderer) since this branch was created independently, off main post-#221, before either batch-1 or batch-2 merged. Narrows jest.config.cjs's untested-component checklist the same way batch-1/2 did: removes SelectionControls (now tested) and reapplies the permanent exclusions (Dialog/ErrorBoundary/Icon/Label/Portal/Scrim/ _internal/Paper/PressableHighlight). Radio and Checkbox tests intentionally exclude the "no onPress provided" scenario for now — see follow-up commit for why.
…cessibilityState
Both components force the underlying Pressable's disabled to true when no
onPress is provided (disabled={!onPress || disabled}), since a control
with nothing to call on press can't meaningfully be interactive. But
accessibilityState.disabled only reflected the raw disabled prop, not
this computed value — so a <Radio checked={false} /> with no onPress was
actually non-interactive while telling assistive technology it wasn't
disabled at all. Same category of bug as #220, different root cause (a
missing factor in the computation, not a merge-order issue).
…ckbox accessibilityState" This reverts commit c04a643.
Verifies a Radio/Checkbox rendered without onPress is safely non-interactive (press is a no-op) and correctly reports disabled to assistive technology. Not a regression test for a fix — React Native's Pressable already normalizes accessibilityState.disabled from its own disabled prop internally (Pressable.js), so this was correct before and after the accessibilityState.disabled computation was touched. An earlier commit on this branch "fixed" this and was reverted once that became clear; this commit is just the leftover, still-valid test coverage.
|
@claude review |
|
Claude finished @Chibuzor-Nwemambu's task in 1m 51s —— View job PR Review — Switch/Radio/Checkbox tests
Reviewed the full diff against What's good ✅
Minor observations (non-blocking, no changes required)
VerificationI did not re-run the suite locally, but the assertions line up with the component source ( Verdict: LGTM 👍 — merge-ready. The two substantive notes (Switch interactivity asymmetry, icon-name coupling) are follow-up/tracking material, not changes to this PR. |
Dialog was previously treated as an internal component with no test file expected, but it still uses the old token system and hasn't been migrated. Add it to the Slice 2-4 exclude lists (tsconfig.json, eslint.config.js, jest.config.cjs) instead.
|
Added |
Summary
test-utils.tsx,@expo/vector-iconsmock,@types/react-test-renderer) duplicated from batch-1/2's branches, since this branch was created independently, offmainpost-fix(components): make component's own disabled state win accessibilityState merges #221, before either batch-1 or batch-2 merged.jest.config.cjs's untested-component checklist the same way batch-1/2 did.Radio/Checkbox(same category as fix(components): component's own disabled state should always win over caller-supplied accessibilityState.disabled #220 — component's real disabled state not reflected inaccessibilityState). Turned out not to be a real bug: React Native'sPressablealready auto-overridesaccessibilityState.disabledfrom its owndisabledprop internally, so the apparent mismatch never manifested at the rendered level. A fix was written, found to be unnecessary once a regression test for it passed against both the pre- and post-fix code, and reverted (commitsc04a643/3798816). The underlying test coverage for the "noonPress" case was kept (40e5559) since it's still valid, correct behavior worth covering.Contributes to #214 — does not close it (the workflow-docs update, batch 4, is still outstanding).
Test plan
pnpm test— 22/22 passing across 3 suitespnpm lint— cleanpnpm check-types— cleanpnpm build— clean